import math
import sys


def compute_score(value, cut, score):
    j = len(cut) - 2
    m = len(cut) - 2
    while j >= 0:
        if value >= cut[j]:
            j = -1
        else:
            j -= 1
            m -= 1
    return score[m]


def get_score(coe, woe, factor):
    scores = []
    for w in woe:
        score = round(coe * w * factor, 0)
        scores.append(score)
    return scores


if __name__ == "__main__":
    coe = [9.356478, 0.660558, 0.512484, 1.015522, 1.745651, 1.100015]
    baseConst = 600
    pdo = 20
    odds = 20
    p = 20 / math.log(2)
    q = baseConst - p * math.log(odds)
    baseScore = round(q + p * coe[0], 0)
    cutx1 = [float('-inf'), 0.0364, 0.179, 0.59, float('inf')]
    cutx2 = [float('-inf'), 33.0, 39.0, 44.0, 48.0, 52.0, 57.0, 61.0, 66.0, 74.0, float('inf')]
    cutx3 = [float('-inf'), 0, 1, 3, 5, float('inf')]
    cutx7 = [float('-inf'), 0, 1, 3, 5, float('inf')]
    cutx9 = [float('-inf'), 0, 1, 3, float('inf')]
    woex1 = [1.348100, 1.172642, 0.266788, -1.095490]
    woex2 = [-0.504465, -0.326766, -0.236323, -0.163238, -0.073448, 0.109963, 0.401052, 0.694668, 1.021821]
    woex3 = [0.521348, -0.862329, -1.690031, -2.388643, -2.587612]
    woex7 = [0.371926, -1.930874, -2.633672, -3.269460, -3.215971]
    woex9 = [0.275740, -1.792477, -2.675943, -3.171020]
    x1 = get_score(coe[1], woex1, p)
    x2 = get_score(coe[2], woex2, p)
    x3 = get_score(coe[3], woex3, p)
    x7 = get_score(coe[4], woex7, p)
    x9 = get_score(coe[5], woex9, p)

    data = sys.argv[1:]
    s1 = compute_score(float(data[0]), cutx1, x1)
    s2 = compute_score(float(data[1]), cutx2, x2)
    s3 = compute_score(float(data[2]), cutx3, x3)
    s7 = compute_score(float(data[3]), cutx7, x7)
    s9 = compute_score(float(data[4]), cutx9, x9)
    s = baseScore + s1 + s2 + s3 + s7 + s9
    print(s)
